# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-ppx_sexp_conv
_pkgname=ppx_sexp_conv
pkgver=0.15.1
pkgrel=1
pkgdesc="[@@deriving] plugin to generate S-expression conversion functions"
url="https://github.com/janestreet/ppx_sexp_conv"
arch="all !riscv64"  # limited by ocaml aport
license="MIT"
depends="ocaml-runtime ocaml-base ocaml-ppxlib ocaml-sexplib0"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-base-dev
	ocaml-ppxlib-dev
	ocaml-sexplib0-dev
	"
makedepends="$depends_dev dune ocaml"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/janestreet/ppx_sexp_conv/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
f2b669e7c7bbbc8dd4978b47b73662dd0195ae85cdd71596485211cb5ab4daedcae9be4b33796674320e0d324b7ee9f90d3b219212be98ed792e3a89ccf8c41b  ocaml-ppx_sexp_conv-0.15.1.tar.gz
"
